/**
 * @file big_numbers.hpp
 * @putpose Infrastructure for big numbers
 */

#ifndef __BIG_NUMBERS_HPP__
#define __BIG_NUMBERS_HPP__

#include <stdexcept>

#define BIG_NUMBERS big_numbers
#define BIG_NUMBERS_NAMESPACE_BEGIN namespace BIG_NUMBERS {
#define BIG_NUMBERS_NAMESPACE_END }

#define BIG_NUMBERS_NAMESPACE_USING using namespace BIG_NUMBERS

// define an empty namespace
BIG_NUMBERS_NAMESPACE_BEGIN

BIG_NUMBERS_NAMESPACE_END

#define DO_ASSERT(condition) do {                                       \
                if (!(condition)) {                                     \
                        printf("%s:%d <%s>: Assertion failed - %s\n",   \
                               __FILE__, __LINE__, __FUNCTION__, #condition); \
                        abort();                                        \
                }                                                       \
        } while (false)

#ifdef NDEBUG
#define ASSERT(condition)
#else // NDEBUG
#define ASSERT(condition) DO_ASSERT(condition)
#endif // NDEBUG

class division_by_zero: public std::runtime_error
{
public:
        division_by_zero(): runtime_error("Division by zero")
        {}
};

class invalid_digit: public std::runtime_error
{
public:
        invalid_digit(): runtime_error("Invalid digit")
        {}
};

#endif // __BIG_NUMBERS_HPP__
